$(document).ready(function() {
	if($("#calendar").length > 0) {
		$('#calendar').fullCalendar({
			header: {
				left: 'prev,next today',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			defaultView: 'agendaWeek',
			allDaySlot: false,
			height: 600,
			scrollTime: '14:00:00',
			lang: 'fr',
			events: BASE_URL+"/instances/event-feed.json",
			eventMouseover: function(calEvent, jsEvent, view) {
				var position = $(this).position();
				var width = $(this).width();
				$.get(BASE_URL+"/instances/event-members-"+calEvent.id+"-feed.json", null,
					function(data){
						$(this).popover({
							title: 'Participants',
							html: true,
							content: data,
							trigger: 'manual',
							placement: 'right',
							container: '.fc-event-container'
						}).popover('show');
						$("div.popover").css({
							top: position.top,
							left: position.left + width
						});
					}, "html"
				);
			},
			eventMouseout: function() {
				$("div.popover").remove();
			}
		});
	}
});